<%@page import="java.util.UUID"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/pages/common/taglib.jsp" %>
<%
    String uuid = UUID.randomUUID().toString();
    request.setAttribute("uuid", uuid);
%>
<style type="text/css">
	.addOrderBtnCss{
		color: red;font-size: 14px;font-weight: bold;cursor: pointer; padding: 2px;
	}
	.riskWO{
		display: none;
	}
	.queryInputLabel{
		color: orange;
	}
	.autoInputLabel{
		color: #3399FF;
	}
	.hide{
		display: none;
	}
</style>
<div class="container-fluid am-margin-top">
    	<form id="workOrderByUserFormHis">
	        <input type="hidden" name="zgdid"/>
	        <!-- 客户信息部分 -->
	        <ul class="nav nav-tabs" role="tablist">
				<li role="presentation" class="active">
					<a href="#${uuid}_clientDataTab" role="tab" data-toggle="tab">
						客户信息
					</a>
				</li>
			</ul>
			<div class="tab-content">
				<div role="tabpanel" class="tab-pane fade in  active am-margin-top-sm" id="${uuid}_clientDataTab">
			        <div class="row">
						<div class="col-md-3">
							<div class="form-group"><label>来电号码</label>
								<input type="text" name="ldhm" class="form-control" check-type="required" readonly="readonly">
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>创建时间</label>
								<div>2016-09-09 12:12:12</div>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>通话时长</label>
								<div>53秒</div>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>业务来源</label>
				                <pf:dataDic var="item" dicCode="YWLY">
				                </pf:dataDic>
				                <div>电话呼入</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-md-3">
							<div class="form-group"><label>客户姓名</label>
								<input type="text" name="khxm" class="form-control" check-type="required" readonly="readonly">
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>客户类型</label>
								<select class="form-control"  name="khlx" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="KHLX">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>客户语言</label>
								<select class="form-control"  name="khyy" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="KHYY">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group" style="padding-top: 25px;">
								<!-- 
								<a href="javascript:void(0)" id="searchOrderBt" class="btn btn-warning">保存更新</a>
								 -->
							</div>
						</div>
					</div>
				</div>
			</div>
			<!-- 客户信息部分结束 -->
		</form>
		<ul class="nav nav-tabs" role="tablist" id="orderNav">
			<li role="presentation" class="active">
				<a href="#${uuid}_fieldDataTab" role="tab" data-toggle="tab">
					工单信息
				</a>
			</li>
		</ul>
		<div class="tab-content" id="orderTab">
				<div role="tabpanel" class="tab-pane fade in  active am-margin-top-sx" id="${uuid}_fieldDataTab">
		   	  	  <form id="workOrderFormHis">
		   	  	  	<input type="hidden" name="id" id="idHis"/>
		   	  	  	<input type="hidden" name="clid"/>
		   	  	  	<input type="hidden" name="gdlcid"/>
		   	  	  	<input type="hidden" name="clzt"/>
		   	  	  	<input type="hidden" name="zhpdsj"/>
		   	  	   　 <!-- 公共上部分 -->
					<div class="row">
						<div class="col-md-3">
							<div class="form-group"><label>业务类型</label>
								<select class="form-control"  name="ywlx" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="YWLX">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>子业务类型</label>
								<select class="form-control"  name="zywlx" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="ZYWLX">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>疑难投诉</label>
								<select class="form-control"  name="ynts" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="YNTS">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<!-- 客服工单部分 -->
						<div class="col-md-3 serviceWO">
							<div class="form-group"><label>客户诉求</label>
								<select class="form-control"  name="khsq" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="KHSQ">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<!-- 客服工单部分结束 -->
					</div>
					<!-- 公共上部分结束 -->
					
					<!-- 风控工单部分 -->
					<div class="row riskWO">
						<div class="col-md-3">
							<div class="form-group"><label class="autoInputLabel">交易手机号是否银行预留手机号</label>
								<select class="form-control"  name="jysjhsfyhylsjh" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>交易手机号是否属于本人</label>
								<select class="form-control"  name="jysjhmsfbr" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>呼叫转移</label>
								<select class="form-control"  name="hjzy" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>短信拦截</label>
								<select class="form-control"  name="dxlj" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
					</div>
					<div class="row riskWO">
						<div class="col-md-3">
							<div class="form-group"><label>接收呼转号码</label>
								<input type="text" class="form-control"  name="jszyhm" readonly="readonly"/>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label class="autoInputLabel">受益人</label>
								<input type="text" class="form-control"  name="syr" readonly="readonly"/>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>是否认识受益人</label>
								<select class="form-control"  name="sfrssydx" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>是否认识交易手机</label>
								<select class="form-control"  name="sfrsjysj" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
					</div>
					<div class="row riskWO">
						<div class="col-md-3">
							<div class="form-group"><label class="autoInputLabel">呼转号码归属地</label>
								<input type="text" class="form-control"  name="hzhmgsd" readonly="readonly"/>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label class="autoInputLabel">呼转号码运营商</label>
								<input type="text" class="form-control"  name="hzhmyys" readonly="readonly"/>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label class="autoInputLabel">受益人手机号</label>
								<input type="text" class="form-control"  name="syrsjh" readonly="readonly"/>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label class="autoInputLabel">受益人手机号归属地</label>
								<input type="text" class="form-control"  name="syrsjhgsd" readonly="readonly"/>
							</div>
						</div>
					</div>
					<div class="row riskWO">
						<div class="col-md-3">
							<div class="form-group"><label>与受益人关系</label>
								<select class="form-control"  name="ysydxgx" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="QSGX">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>手机品牌</label>
								<select class="form-control"  name="sjpp" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SJPP">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>手机系统</label>
								<select class="form-control"  name="sjxt" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SJXT">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>银行卡信息泄露</label>
								<select class="form-control"  name="yhkxxxl" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
					</div>
					<div class="row riskWO">
						<div class="col-md-3">
							<div class="form-group"><label>ID是否被盗</label>
								<select class="form-control"  name="idsfxl" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>ID注册邮箱</label>
								<select class="form-control"  name="idzcyx" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>是否报警</label>
								<select class="form-control"  name="sfbj" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
						<div class="col-md-3">
							<div class="form-group"><label>手机系统是否越狱</label>
								<select class="form-control"  name="sjsfyy" check-type="required" disabled="disabled">
					                <pf:dataDic var="item" dicCode="SF">
					                    <option value="${item.value}">${item.name}</option>
					                </pf:dataDic>
					            </select>
							</div>
						</div>
					</div>
					<div class="row riskWO">
						<div class="col-md-12">
							<div class="form-group"><label>银行账号绑定业务情况</label>
								<pf:dataDic var="item" dicCode="BDYW">
					                    &nbsp;&nbsp;${item.name}&nbsp;<input type="checkbox" name="yhkbdyw" value="${item.value}" disabled="disabled">
					            </pf:dataDic>
					            <input type="text" class="form-control"  name="bdywbc" readonly="readonly" placeholder="其他说明"/>
							</div>
						</div>
					</div>
					<!-- 风控工单部分结束 -->
					
					<!-- 公共下部分 -->
					<div class="row">
						<div class="col-md-12">
							<div class="form-group"><label>客户投诉</label>
								<textarea name="khtsbt"  class="form-control" check-type="required" readonly="readonly"></textarea>
							</div>
						</div>
					</div>
					<!-- 
					<div class="row">
						<div class="col-md-12">
							<div class="form-group"><label>受理情况</label>
								<textarea name="slqk"  class="form-control" check-type="required" readonly="readonly"></textarea>
							</div>
						</div>
					</div>
					 -->
					<div class="row">
						<div class="col-md-4">
							<div class="form-group"><label class="autoInputLabel">关联交易笔数</label>
								<input type="text" class="form-control" id="tradCount" name="gljybs" value="0" readonly="readonly"/>
							</div>
						</div>
						<div class="col-md-4">
							<div class="form-group"><label class="autoInputLabel">关联交易金额</label>
								<input type="text" class="form-control" id="tradJe" name="gljyje" value="0.00" readonly="readonly"/>
							</div>
						</div>
					</div>
					<!-- 公共下部分结束 -->
					
					<!-- 关联交易列表 -->
				   	<div class="box-body">
				   		<input type="hidden" name="joinTradIdsHis" value=""/>
						<table id="iWorkOrderSelGrid_${uuid}_d">
				   		</table>
					</div>
					<!-- 关联交易列表结束 -->
					
				</div>
				<div role="tabpanel" class="tab-pane fade am-margin-top-sm" id="${uuid}_formViewTab">
	       	   </form>
			 </div>
		</div>
		
		<!-- 受理情况部分 -->
		<ul class="nav nav-tabs" role="tablist" id="orderNav">
			<li role="presentation" class="active">
				<a href="#${uuid}_fieldDataTab" role="tab" data-toggle="tab">
					受理情况
				</a>
			</li>
		</ul>
		<div class="tab-content">
			<div class="box-body">
				<table id="iWorkOrderAcceptGridHis${uuid}">
		   		</table>
			</div>
		</div>
		<div class="row">
		   <form id="workOrderAccept">
				<div class="col-md-12">
					<div class="form-group"><label id="zhpdtime">&nbsp;</label>
						<div class="checkbox">
				            <button type="button" class="btn btn-warning" id="reDealBtn">重启工单</button>
				        </div>
					</div>
				</div>
		   </form>
		</div>
		<!-- 受理情况部分结束 -->
		
</div>
<script type="text/javascript">
	
    $(function () {
    	
    	webUtils.nameSpace("wiseMen.workOrder");
    	
    	//初始化关联交易列表方法 
    	wiseMen.workOrder.loadTableGridHis=function(uuid,index){
	    	var iworkOrderSelGrid = $("#iWorkOrderSelGrid_"+uuid+"_d").bootstrapTable({
	        	url:ctx + "/workOrderAct/queryTarding.do",
	        	columns:[
	    			{title: '关联' , field: 'ID' , width: "50px",formatter:function(data, row, index){
	    					return '<input type="checkbox" id="'+row.ID+'" ddh="'+row.YLDDH+'" je="'+row.JYJE+'" onclick="javascript:wiseMen.workOrder.checkJoin(this);"></input>';
	    				}
	    			},
	    			{title: '开户姓名', field: 'KHXM'},
	    			{title: '交易手机', field: 'JYSJH'},
	    			{title: '银行卡号', field: 'YHZH'},
	    			{title: '银行', field: 'YH'},
	    			{title: '卡种', field: 'KZ'},
	    			{title: '商店名称', field: 'SDMC'},
	    			{title: '商品描述', field: 'SPMS'},
	                {title: '易联订单号', field: 'YLDDH'},
	                {title: '商户订单号', field: 'SHDDH'},
	                {title: '交易金额', field: 'JYJE'},
	                {title: '人民币金额', field: 'RMBJE'},
	                {title: '交易时间', field: 'JYSJ'},
	                {title: '状态', field: 'DDZT'},
	                {title: '支付结果', field: 'ZFJG'},
	                {title: '详细', field: 'ID',formatter:function(data, row, index){
	                	var btn = '<button data-rowindex="0" type="button" title="查看" class="btn btn-default btn-xs am-margin-left-xs am-margin-vertical-xs inGridOptBtn" onclick="javascript:wiseMen.workOrder.tradingView(\''+uuid+'\',\''+index+'\')"><span class="glyphicon glyphicon-search"></span></button>';
	                	return btn;
	                }}
	        	],
	    	    queryParams: function(d) {
	    	        d.ids = $("input[name=joinTradIdsHis").val();
	    	        return d;
	    	    }
	        });
	        $("#"+uuid+"_fieldDataTab"+index).find("#searchSelOrderBt").click(function(){
	        	iworkOrderSelGrid.bootstrapTable("refresh");
	        });
    	}
    	
    	//加载表单初始化数据
        var id = '${param.id}';
        var clid = '${param.clid}';
        var winId = '${param.winId}';
        if (id) {
            $.getJSON(ctx + '/workOrderAct/queryWorkOrderDealById.do', {id: id,clid:clid}, function (data) {
                //初始化表单数据
            	webUtils.fullForm({
                    form:$("#workOrderByUserFormHis"),
                    data: data.order
                });
                webUtils.fullForm({
                    form: $("#workOrderFormHis"),
                    data: data.order
                });
                //初始化已关联交易
                var tradIds = '';
                $.each(data.joinTrad,function(index,obj){
                    if(tradIds!=''){
                    	tradIds+=',';
                    }
                    tradIds+="'"+obj.TID+"'";
                });
                $("input[name=joinTradIdsHis]").val(tradIds);
				//初始化风控/客服可见数据项
            	wiseMen.workOrder.ywlxSelEvent();
            	//初始化第一个工单所关联的交易列表
            	wiseMen.workOrder.loadTableGridHis('${uuid}','');
            	//判断是否已办结
            	if(data.order.gdclzt!='2'){
            		$("#reDealBtn").hide();
            	}
            });
        }
        
        //重启工单
        $("#reDealBtn").click(function(){
        	var windSet=webUtils.dialog({
	          	 title:'重启工单',
	          	 url:ctx + "/workOrderAct/setReStartDeal.do?winId=setReDeal",
	          	 width:400,
	          	 height:260
	        });
	        webUtils.topicSubscribe("dialog.submit.success.setReDeal",function(data){
	        	$.post(ctx + '/workOrderAct/reStartDeal.do',{id:$("#idHis").val(),cqbj:"1",cqyy:data.cqyy},function (ndata) {
	                    if (ndata.success) {
	                    	layer.msg("重启工单操作成功！");
	                    	 webUtils.topicPublish("dialog.submit.success."+winId, ndata);
	                    } else {
	                    	webUtils.error(data.msg);
	                    }
               		}
            	);
            	windSet.close();
			},true);
        });
        
        wiseMen.workOrder.acceptTableGridHis = null;
    	wiseMen.workOrder.loadAcceptTableGridHis=function(uuid){
    		requirejs(['wiseMen/dataModel/QueryDefTpl'],function(QueryDefTpl){
    			wiseMen.workOrder.acceptTableGridHis=new QueryDefTpl({
	    			code:"DM_WORKORDER_DEAL",
	    			searchBarType:"dialog",
	    			selectModel:"single",
	    			gridDiv:"#iWorkOrderAcceptGridHis"+uuid,
	    			queryDatas:{YWGDID:id,CLZT:'-1'}
	    		});
    		});
    	}
    	wiseMen.workOrder.loadAcceptTableGridHis('${uuid}');
        
    });    
</script>
